import { Input } from "antd"
import React, { FC } from "react"

import { SFormItem } from "@/components/common"
import { useLocale } from "@/locales"

const TextInput: FC<any> = ({
	labelId = "member.ip_attribution",
	placeholderId = "risk.please_enter_login_Ip",
	fieldName = "ipAttribution",
	isHideLabel = false,
	rules = [],
	isDisabled = false,
	style = {},
	normalize = undefined
}) => {
	const { formatMessage } = useLocale()
	const defaultNormalize = (value: string) => value.replaceAll(" ", "") || undefined

	return (
		<SFormItem
			name={fieldName}
			label={isHideLabel ? "" : labelId === "noId" ? undefined : formatMessage({ id: labelId })}
			rules={rules}
			normalize={normalize || defaultNormalize}
		>
			<Input style={style} allowClear placeholder={formatMessage({ id: placeholderId })} disabled={isDisabled} />
		</SFormItem>
	)
}

export default TextInput
